<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en-us" xml:lang="en-us">
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="DC.Type" content="topic">
  <meta name="DC.Title" content="Step 3: Registering the Database of a Single PostgreSQL Instance">
  <meta name="product" content="">
  <meta name="DC.Relation" scheme="URI" content="en-us_topic_0000002200004613.html">
  <meta name="prodname" content="">
  <meta name="version" content="">
  <meta name="brand" content="">
  <meta name="DC.Publisher" content="20250306">
  <meta name="prodname" content="csbs">
  <meta name="documenttype" content="usermanual">
  <meta name="DC.Format" content="XHTML">
  <meta name="DC.Identifier" content="EN-US_TOPIC_0000002164603858">
  <meta name="DC.Language" content="en-us">
  <link rel="stylesheet" type="text/css" href="public_sys-resources/commonltr.css">
  <title>Step 3: Registering the Database of a Single PostgreSQL Instance</title>
 </head>
 <body style="clear:both; padding-left:10px; padding-top:5px; padding-right:5px; padding-bottom:5px">
  <a name="EN-US_TOPIC_0000002164603858"></a><a name="EN-US_TOPIC_0000002164603858"></a>
  <h1 class="topictitle1">Step 3: Registering the Database of a Single PostgreSQL Instance</h1>
  <div>
   <div class="section">
    <h4 class="sectiontitle">Prerequisites</h4>
    <ul>
     <li>For 1.6.0 and later versions, before registering an instance, check whether the owner of the <strong>bin/lib/share</strong> file in the database installation path is <strong>root</strong>. If the owner is <strong>root</strong>, set <strong>enable_root</strong> to <strong>1</strong> in the <strong>/opt/DataBackup/ProtectClient/Plugins/GeneralDBPlugin/bin/applications/postgresql/conf/switch.conf</strong> configuration file.</li>
     <li>When backing up PostgreSQL database instances in the High Availability Cluster Server (HACS) scenario, the <span>product</span> supports only the backup of the PostgreSQL database in a single instance.</li>
     <li>Before registering a database account, ensure that the account has the following minimum permissions. The configuration method is as follows. Account <strong>teste_bkp</strong> is used as an example.
      <ol>
       <li id="EN-US_TOPIC_0000002164603858__li1919772032716"><a name="EN-US_TOPIC_0000002164603858__li1919772032716"></a><a name="li1919772032716"></a>Login permissions: The database account must be used to log in the specified database during registration of a single PostgreSQL instance database, backup, and restoration. Therefore, you must run the <strong>CREATE ROLE teste_bkp LOGIN PASSWORD 'teste_bkp'</strong><strong>;</strong> command so that the account has the basic login permissions. In addition, run the following commands to log in to the database and view the database version. In the commands, <em>/usr/local/pgsql/bin/psql</em> indicates the path of the <strong>psql</strong> script, <strong>-h</strong> indicates the IP address of the host where the database instance resides, and <strong>-p</strong> indicates the port number of the database instance.<pre class="screen" id="EN-US_TOPIC_0000002164603858__screen1310223250">su - postgres
su - postgres -c '<em id="EN-US_TOPIC_0000002164603858__i7325132282020">/usr/local/pgsql/bin/psql</em> -h <em id="EN-US_TOPIC_0000002164603858__i338515391176">Database IP address</em> -p <em id="EN-US_TOPIC_0000002164603858__i1842183141616">Port number</em> -U <strong id="EN-US_TOPIC_0000002164603858__b1263531512614">teste_bkp</strong> -d postgres' </pre>
        <div class="note" id="EN-US_TOPIC_0000002164603858__note163113935012">
         <img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span>
         <div class="notebody">
          <p id="EN-US_TOPIC_0000002164603858__p11636396502">If the queried database version is earlier than 10.0, the database account must be <strong id="EN-US_TOPIC_0000002164603858__b1720055433518">SUPERUSER</strong> and you do not need to perform <a href="#EN-US_TOPIC_0000002164603858__li14737182342715">2</a> and <a href="#EN-US_TOPIC_0000002164603858__li3687112632718">3</a>.</p>
         </div>
        </div></li>
       <li id="EN-US_TOPIC_0000002164603858__li14737182342715"><a name="EN-US_TOPIC_0000002164603858__li14737182342715"></a><a name="li14737182342715"></a>Permissions to read the configuration file: After logging in to the database, run the <strong id="EN-US_TOPIC_0000002164603858__b549614151116">GRANT pg_read_all_settings TO teste_bkp;</strong> command to set the permissions.</li>
       <li id="EN-US_TOPIC_0000002164603858__li3687112632718"><a name="EN-US_TOPIC_0000002164603858__li3687112632718"></a><a name="li3687112632718"></a>Permissions to execute functions: To perform backup, you must have the execute permissions on the <strong id="EN-US_TOPIC_0000002164603858__b154923194155">pg_backup_start</strong> and <strong id="EN-US_TOPIC_0000002164603858__b19492111918158">pg_backup_stop</strong> functions. Grant the execute permissions on the functions as follows:<p id="EN-US_TOPIC_0000002164603858__p710125393320">If the version queried in <a href="#EN-US_TOPIC_0000002164603858__li1919772032716">1</a> is 15.0 or later, run the following commands to grant permissions:</p> <p id="EN-US_TOPIC_0000002164603858__p3548204552719">(1) Granting permissions to execute the <strong id="EN-US_TOPIC_0000002164603858__b192871132201810">pg_backup_start</strong> function: <strong id="EN-US_TOPIC_0000002164603858__b828713281814">GRANT EXECUTE ON FUNCTION pg_backup_start TO teste_bkp;</strong></p> <p id="EN-US_TOPIC_0000002164603858__p6581458122212">(2) Granting permissions to execute the <strong id="EN-US_TOPIC_0000002164603858__b625125813177">pg_backup_stop</strong> function: <strong id="EN-US_TOPIC_0000002164603858__b72921811134">GRANT EXECUTE ON FUNCTION pg_backup_stop TO teste_bkp;</strong></p> <p id="EN-US_TOPIC_0000002164603858__p1381017559336">If the version is 9.6 or is later than 9.6 but earlier than 15.0, run the following commands to grant permissions:</p> <p id="EN-US_TOPIC_0000002164603858__p11600185385218">(1) Granting permissions to execute the <strong id="EN-US_TOPIC_0000002164603858__b18695148229">pg_backup_start</strong> function: <strong id="EN-US_TOPIC_0000002164603858__b369515414227">GRANT EXECUTE ON FUNCTION pg_start_backup(text,boolean,boolean) TO teste_bkp;</strong></p> <p id="EN-US_TOPIC_0000002164603858__p17600195335218">(2) Granting permissions to execute the <strong id="EN-US_TOPIC_0000002164603858__b048612642217">pg_backup_stop</strong> function: <strong id="EN-US_TOPIC_0000002164603858__b1548672612227">GRANT EXECUTE ON FUNCTION pg_stop_backup() TO teste_bkp;</strong></p> <p id="EN-US_TOPIC_0000002164603858__p113810115324">If the version is earlier than 9.6, run the following commands to grant permissions:</p> <p id="EN-US_TOPIC_0000002164603858__p1338151113210">(1) Granting permissions to execute the <strong id="EN-US_TOPIC_0000002164603858__b1737175772216">pg_backup_start</strong> function: <strong id="EN-US_TOPIC_0000002164603858__b10384578227">GRANT EXECUTE ON FUNCTION pg_start_backup(text,boolean) TO teste_bkp;</strong></p> <p id="EN-US_TOPIC_0000002164603858__p33831112327">(2) Granting permissions to execute the <strong id="EN-US_TOPIC_0000002164603858__b1819901302314">pg_backup_stop</strong> function: <strong id="EN-US_TOPIC_0000002164603858__b12002134237">GRANT EXECUTE ON FUNCTION pg_stop_backup() TO teste_bkp;</strong></p></li>
      </ol></li>
    </ul>
   </div>
   <div class="section">
    <h4 class="sectiontitle">Procedure</h4>
    <ol>
     <li><span>Choose <span class="uicontrol" id="EN-US_TOPIC_0000002164603858__en-us_topic_0000002199964685_uicontrol1389612810362"><b><span id="EN-US_TOPIC_0000002164603858__en-us_topic_0000002199964685_text1089610893610"><strong>Protection</strong></span> &gt; Databases &gt; PostgreSQL</b></span>.</span></li>
     <li><span>Click the <span class="uicontrol"><b>Instance</b></span> tab.</span></li>
     <li><span>Click <span class="uicontrol"><b><span><strong>Register</strong></span></b></span> to register a PostgreSQL database.</span></li>
     <li><span>Set <span class="uicontrol"><b><span><strong>Type</strong></span></b></span> to <span class="uicontrol"><b><span><strong>Single instance</strong></span></b></span>.</span></li>
     <li><span>Configure the database instance and its authentication information.</span><p></p><p><a href="#EN-US_TOPIC_0000002164603858__en-us_topic_0000001311214069_table241515964115">Table 1</a> describes related parameters.</p>
      <div class="tablenoborder">
       <a name="EN-US_TOPIC_0000002164603858__en-us_topic_0000001311214069_table241515964115"></a><a name="en-us_topic_0000001311214069_table241515964115"></a>
       <table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000002164603858__en-us_topic_0000001311214069_table241515964115" frame="border" border="1" rules="all">
        <caption>
         <b>Table 1 </b>Registration information of a single PostgreSQL instance
        </caption>
        <colgroup>
         <col style="width:25.629999999999995%">
         <col style="width:74.37%">
        </colgroup>
        <thead align="left">
         <tr>
          <th align="left" class="cellrowborder" valign="top" width="25.629999999999995%" id="mcps1.3.2.2.5.2.2.2.3.1.1"><p>Parameter</p></th>
          <th align="left" class="cellrowborder" valign="top" width="74.37%" id="mcps1.3.2.2.5.2.2.2.3.1.2"><p>Description</p></th>
         </tr>
        </thead>
        <tbody>
         <tr>
          <td class="cellrowborder" valign="top" width="25.629999999999995%" headers="mcps1.3.2.2.5.2.2.2.3.1.1 "><p><span><strong>Name</strong></span></p></td>
          <td class="cellrowborder" valign="top" width="74.37%" headers="mcps1.3.2.2.5.2.2.2.3.1.2 "><p>Name of the user used for installing the database, which is user-defined.</p></td>
         </tr>
         <tr>
          <td class="cellrowborder" valign="top" width="25.629999999999995%" headers="mcps1.3.2.2.5.2.2.2.3.1.1 "><p><span><strong>Hosts</strong></span></p></td>
          <td class="cellrowborder" valign="top" width="74.37%" headers="mcps1.3.2.2.5.2.2.2.3.1.2 "><p>Select the database host to be registered.</p></td>
         </tr>
         <tr>
          <td class="cellrowborder" valign="top" width="25.629999999999995%" headers="mcps1.3.2.2.5.2.2.2.3.1.1 "><p><span><strong>Username</strong></span></p></td>
          <td class="cellrowborder" valign="top" width="74.37%" headers="mcps1.3.2.2.5.2.2.2.3.1.2 "><p>Name of the OS user who runs the database. The default username is <strong>postgres</strong>.</p></td>
         </tr>
         <tr>
          <td class="cellrowborder" valign="top" width="25.629999999999995%" headers="mcps1.3.2.2.5.2.2.2.3.1.1 "><p><span><strong>Database Installation Path</strong></span></p></td>
          <td class="cellrowborder" valign="top" width="74.37%" headers="mcps1.3.2.2.5.2.2.2.3.1.2 "><p>Installation path of the database to be registered. You can use PuTTY to log in to the PostgreSQL database host and run the <strong>ps -ef | grep postgres</strong> command to query it, as shown in the following figure.</p> <p><span><img src="en-us_image_0000002228527909.png"></span></p></td>
         </tr>
         <tr>
          <td class="cellrowborder" valign="top" width="25.629999999999995%" headers="mcps1.3.2.2.5.2.2.2.3.1.1 "><p><strong>Database Archive Path</strong></p></td>
          <td class="cellrowborder" valign="top" width="74.37%" headers="mcps1.3.2.2.5.2.2.2.3.1.2 "><p>Path for archiving the database to be registered.</p>
           <div class="note">
            <span class="notetitle"> NOTE: </span>
            <div class="notebody">
             <p>Run the <strong>su - postgres -c "<em>/usr/local/pgsql/bin/psql</em> -U postgres -h <em>Database IP address</em> -p <em>Port number</em> -d postgres -W -H -c 'show archive_command'"</strong> command to query the archive path. In the command, <em>/usr/local/pgsql/bin/psql</em> indicates the <strong>psql</strong> script path, <strong>-h</strong> indicates the IP address of the host where the database instance resides, and <strong>-p</strong> indicates the port number of the database instance. To obtain the values of <span class="uicontrol"><b>-h</b></span> and <span class="uicontrol"><b>-p</b></span>, log in to the CLup database management page, choose <strong>Instance</strong> &gt; <strong>Instance List</strong> to go to the <strong>DB Instance List</strong> page, and obtain the values of <strong>Host</strong> and <strong>Port</strong>.</p>
            </div>
           </div></td>
         </tr>
         <tr>
          <td class="cellrowborder" valign="top" width="25.629999999999995%" headers="mcps1.3.2.2.5.2.2.2.3.1.1 "><p><span><strong>Service Plane IP Address</strong></span></p></td>
          <td class="cellrowborder" valign="top" width="74.37%" headers="mcps1.3.2.2.5.2.2.2.3.1.2 "><p>IP address of the host for the database service to receive TCP/IP connections, that is, the host IP address registered with the <span>product</span>.</p></td>
         </tr>
         <tr>
          <td class="cellrowborder" valign="top" width="25.629999999999995%" headers="mcps1.3.2.2.5.2.2.2.3.1.1 "><p><span><strong>Database Port</strong></span></p></td>
          <td class="cellrowborder" valign="top" width="74.37%" headers="mcps1.3.2.2.5.2.2.2.3.1.2 "><p>Port used by the database service to listen on TCP/IP connections. The default port number is <strong>5432</strong>.</p></td>
         </tr>
         <tr>
          <td class="cellrowborder" valign="top" width="25.629999999999995%" headers="mcps1.3.2.2.5.2.2.2.3.1.1 "><p><span><strong>Database Username</strong></span></p></td>
          <td class="cellrowborder" valign="top" width="74.37%" headers="mcps1.3.2.2.5.2.2.2.3.1.2 "><p>Name of the database administrator. Obtain the value from the database administrator.</p></td>
         </tr>
         <tr>
          <td class="cellrowborder" valign="top" width="25.629999999999995%" headers="mcps1.3.2.2.5.2.2.2.3.1.1 "><p><span><strong>Database Password</strong></span></p></td>
          <td class="cellrowborder" valign="top" width="74.37%" headers="mcps1.3.2.2.5.2.2.2.3.1.2 "><p>Password of the database administrator. Obtain the value from the database administrator.</p></td>
         </tr>
        </tbody>
       </table>
      </div> <p></p></li>
     <li><span>Click <span class="uicontrol"><b>OK</b></span>.</span></li>
    </ol>
   </div>
  </div>
  <div>
   <div class="familylinks">
    <div class="parentlink">
     <strong>Parent topic:</strong> <a href="en-us_topic_0000002200004613.html">Backing Up PostgreSQL</a>
    </div>
   </div>
  </div>
 </body>
</html>